package comparator;

import java.util.Arrays;
import java.util.Comparator;

public class Test1 {
    public static void main(String[] args) {
        int i='0';
        System.out.println(i);
        test();
        test2();
    }

    public static void test() {
        int[] i = {3, 56, 1, 4, 534, 123, 4, 3, 5, 6, 7, 8, 9, 0};
        double[] d = {1.2, 3.4, 5.6, 7.8, 1.2, 3.4, 5.6, 7.8, 9.0};
        String[] s = {"a", "ae", "fc", "aag", "b", "cs", "n", "o"};
        Arrays.sort(i);
        Arrays.sort(d);
        Arrays.sort(s);
        //直接打印是存放在堆内存中的地址
        System.out.println(Arrays.toString(i));
        System.out.println(Arrays.toString(d));
        System.out.println(Arrays.toString(s));
    }

    public static void test2() {
        Student student2 = new Student("ls", 19, 99);
        Student student1 = new Student("zs", 118, 100);
        Student student3 = new Student("zs", 20, 98);
        Student[] students = {student1, student2, student3};

        Comparator<Student> c = (o1, o2) -> o2.getScore() - o1.getScore();
        Arrays.sort(students, ((o1, o2) -> {
            int i = o2.getName().compareTo(o1.getName());
            if(i == 0){
                i= o2.getAge() - o1.getAge();
            }
            return i;
        }));

        Arrays.stream(students).forEach(System.out::println);
    }
}
